#ifndef __UTIL_H__
#define __UTIL_H__

////////////////////////////////////////////////////////
//useful 16/32 bit portable macros
#ifdef _WIN32
#define MEMSET			memset
#define MEMCPY			memcpy
#ifdef  UNICODE
	#define STRNCPY			wcsncpy
#else
	#define STRNCPY			strncpy
#endif
#define MALLOC			malloc
#define FREE				free
#ifdef UNDER_CE
	#define HEAPMIN()
#else
	#define HEAPMIN			_heapmin
#endif
#define STRICMP			lstrcmp
#define STRTOK			strtok
#else
#define MEMSET			_fmemset
#define MEMCPY			_fmemcpy
#define STRNCPY			_fstrncpy
#define MALLOC			_fmalloc
#define FREE				_ffree
#define HEAPMIN			_fheapmin
#define STRICMP			_fstricmp
#define STRTOK			_fstrtok
#define SHORT				WORD
typedef LPSTR PTSTR, LPTSTR;
typedef LPCSTR PCTSTR, LPCTSTR;
//typedef char				WCHAR;
//typedef WCHAR TCHAR, *PTCHAR;
#endif
////////////////////////////////////////////////////////

//misc macros
#define RCHEIGHT(x)	(x.bottom - x.top)
#define RCWIDTH(x)	(x.right - x.left)
////////////////////////////////////////////////////////

#if defined( __cplusplus )
extern "C" {
#endif

LPTSTR WINAPI zap(LPTSTR, int);
void WINAPI StripNull(LPTSTR, int);
void WINAPI CobCopy(LPTSTR, LPCTSTR, int);
LPTSTR WINAPI CobToC(LPTSTR, LPTSTR, int);
int WINAPI CentredMessageBox(HWND, LPTSTR, LPTSTR, UINT);
void WINAPI CenterDialog(HWND);
void WINAPI CenterDialogOnScreen(HWND);
void WINAPI Paint3dFrame(HDC, LPRECT, BOOL);
int WINAPI GetWindowHeight(HWND);
int WINAPI GetWindowWidth(HWND);
BOOL WINAPI StrMatch(LPTSTR lpsz, LPTSTR lpszMatch);
BOOL WINAPI StrMatchNoCase(LPTSTR lpsz, LPTSTR lpszMatch);
void Compress(LPSTR pDataIn, int cbIn, LPSTR pDataOut, LPINT pcbOut);
void Uncompress(LPSTR pDataIn, int cbIn, LPSTR pDataOut, LPINT pcbOut);
#ifdef WIN32
LPTSTR StrEllipsis(LPTSTR lpszIn, LPTSTR lpszOut, int cx, HDC hDC);
int WINAPI GetUniqueId(void);
#endif

#ifdef UNDER_CE
#define GHND 0
HANDLE GlobalAlloc(int, DWORD);
void* GlobalLock(HANDLE);
HANDLE GlobalFree(HANDLE);
#endif

#if defined( __cplusplus )
}
#endif

#endif //__UTIL_H__
